//
//  GoodsSelectedTableViewCell.m
//  quxiangtao
//
//  Created by xbmios on 2018/7/26.
//  Copyright © 2018年 shanhaijin. All rights reserved.
//

#import "GoodsSelectedTableViewCell.h"

@interface GoodsSelectedTableViewCell ()

//@property (strong, nonatomic) UILabel *titleL;
//@property (strong, nonatomic) UILabel *desL;
@property (strong, nonatomic) UIImageView *arrowIV;
@property (strong, nonatomic) UIImageView *addressIV;

@property (strong, nonatomic) UIView *lineV;

@end

@implementation GoodsSelectedTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self.contentView addSubview:self.titleL];
        [self.contentView addSubview:self.arrowIV];
        [self.contentView addSubview:self.addressIV];
        [self.contentView addSubview:self.desL];
        [self.contentView addSubview:self.lineV];
        
    }
    
    return self;
}

- (void)setItemNum:(NSInteger)itemNum {
    
    _itemNum = itemNum;

    __weak typeof(self) weakSelf = self;
    
    if (itemNum == 1) {

        [self.addressIV mas_makeConstraints:^(MASConstraintMaker *make) {

            make.left.mas_equalTo(weakSelf.titleL.mas_right).with.offset(jisuan(60));
            make.centerY.mas_equalTo(weakSelf.titleL.mas_centerY);
            make.width.mas_equalTo(jisuan(30));
            make.height.mas_equalTo(jisuan(30));
        }];
        [self.desL mas_makeConstraints:^(MASConstraintMaker *make) {

            make.left.mas_equalTo(weakSelf.addressIV.mas_right).with.offset(jisuan(10));
            make.centerY.mas_equalTo(weakSelf.titleL.mas_centerY);
            make.right.mas_equalTo(weakSelf.contentView.mas_right).with.offset(-jisuan(52));
            make.height.mas_equalTo(jisuan(80));
        }];

    }else {

        [self.desL mas_makeConstraints:^(MASConstraintMaker *make) {

            make.left.mas_equalTo(weakSelf.titleL.mas_right).with.offset(jisuan(60));
            make.centerY.mas_equalTo(weakSelf.titleL.mas_centerY);
        }];
    }

}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    __weak typeof(self) weakSelf = self;
    [self.titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.contentView.mas_left).with.offset(jisuan(20));
        make.centerY.mas_equalTo(weakSelf.contentView.mas_centerY);
        make.width.mas_equalTo(jisuan(60));
        make.height.mas_equalTo(jisuan(80));
    
    }];

    [self.arrowIV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_equalTo(weakSelf.contentView.mas_right).with.offset(-jisuan(20));
        make.centerY.mas_equalTo(weakSelf.contentView.mas_centerY);
        make.width.mas_equalTo(jisuan(12));
        make.height.mas_equalTo(jisuan(20));
    }];
    [self.lineV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.contentView.mas_left);
        make.right.mas_equalTo(weakSelf.contentView.mas_right);
        make.bottom.mas_equalTo(weakSelf.contentView.mas_bottom);
        make.height.mas_equalTo(jisuan(2));
        
    }];
    
}

#pragma mark -lazy
- (UILabel *)titleL {
    
    if (!_titleL) {
     
        _titleL = [[UILabel alloc] init];
        _titleL.font = Font(24);
        _titleL.textColor = Color999999;
        _titleL.textAlignment = NSTextAlignmentLeft;
    }
    
    return _titleL;
}
- (UILabel *)desL {
    
    if (!_desL) {
        
        _desL = [[UILabel alloc] init];
        _desL.font = Font(24);
        _desL.textColor = Color333333;
        _desL.textAlignment = NSTextAlignmentLeft;
    }
    
    return _desL;
}

- (UIImageView *)addressIV {
    
    if (!_addressIV) {
        
        _addressIV = [[UIImageView alloc] init];
        _addressIV.contentMode = UIViewContentModeScaleAspectFit;
        _addressIV.image = [UIImage imageNamed:@"goodsContentAddressBG"];
    }
    
    return _addressIV;
}

- (UIImageView *)arrowIV {
    
    if (!_arrowIV) {
        
        _arrowIV = [[UIImageView alloc] init];
        _arrowIV.contentMode = UIViewContentModeScaleAspectFit;
        _arrowIV.image = [UIImage imageNamed:@"rightArrowBG"];
    }
    
    return _arrowIV;
}

- (UIView *)lineV {
    
    if (!_lineV) {
        
        _lineV = [[UIView alloc] init];
        _lineV.backgroundColor = Colordddddd;
    }
    
    return _lineV;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
